package spe.ui.editor.policy;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy;
import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.ReconnectRequest;

import spe.model.notation.Link;
import spe.model.spem.NodeElement;
import spe.ui.editor.command.LinkCreateLinkCommand;

public class SPEMGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy
{
	@Override
	protected Command getConnectionCompleteCommand(CreateConnectionRequest rq) 
	{
		//System.out.println(String.format("[SPEMGraphicalNodeEditPolicy] rq %s", rq));
		LinkCreateLinkCommand cmd = (LinkCreateLinkCommand)rq.getStartCommand();
		cmd.setTarget((NodeElement)(getHost().getModel()));
		return cmd;
	}

	@Override
	protected Command getConnectionCreateCommand(CreateConnectionRequest rq) 
	{
		//System.out.println(String.format("[SPEMGraphicalNodeEditPolicy] rq %s", rq));
		LinkCreateLinkCommand cmd = new LinkCreateLinkCommand();
		cmd.setLink((Link) rq.getNewObject());
		cmd.setSource((NodeElement) getHost().getModel());
		rq.setStartCommand(cmd);
		return cmd;
	}

	@Override
	protected Command getReconnectSourceCommand(ReconnectRequest arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected Command getReconnectTargetCommand(ReconnectRequest arg0) {
		// TODO Auto-generated method stub
		return null;
	}

}
